<?php
/**
 * Created by Chongyi
 * Date: 2015/10/5 0005
 * Time: 上午 11:33
 */

namespace App\B2BProject\Admin\Authority\Rbac;


use App\B2BProject\Admin\Administrator;

trait AdminTrait
{
    public static function boot()
    {
        parent::boot();

        static::deleting(function($user) {
            if (!method_exists(Administrator::class, 'bootSoftDeletingTrait')) {
                $user->roles()->sync([]);
            }

            return true;
        });
    }

    public function roles()
    {
        return $this->belongsToMany('App\B2BProject\Admin\Authority\Rbac\Role');
    }

    public function hasRole($name)
    {

    }
}